package org.jtb.quickr;

import java.io.InputStream;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

class PeopleFindByUsernameRequest extends MethodRequest {
    private String userName;
    
    protected PeopleFindByUsernameRequest(String baseUrl, String apiKey, String userName) throws QuickrException {
        super(baseUrl, apiKey, "flickr.people.findByUsername");
        this.userName = userName;
    }
        
    protected Map<String,String> getArgs() {
        putArg("username", getUserName());      
        
        return super.getArgs();
    }

    public UserResponse execute() throws QuickrException {
        FlickrUrl furl = new ServiceMethodUrl(getBaseUrl(), getArgs(), getApiKey(), getMethod());
        Get get = new Get(furl.getUrl());
        InputStream is = get.execute();

        UserResponse ures = new UserResponse(is);
        
        return ures;
    }

    protected String getUserName() {
        return userName;
    }
}
